package com.hc.window.textFileManageView;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JLabel;

import com.hc.util.CommonData;
import com.hc.util.CommonView;

public class ItemHeadLabel extends JLabel implements MouseListener{
	private String text;
	private String filePath;
	public ItemHeadLabel(String text,String filePath) {

		setForeground(new Color(30, 144, 255));
		this.text = text;
		this.filePath = filePath;
		this.setText(text);
		
		this.addMouseListener(this);
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		
		CommonData.nowFilePath = this.filePath;
		
		
		CommonView.todoItemPanel.refreshView(filePath);
		
		
		boolean state = false;
		
		int size = CommonView.todoItemPanel.ItemHeadLabelList.size();
		int num = 0;
		for(int i =0;i<size;i++){
			if(state){
				
				 CommonView.todoItemPanel.ItemHeadLabelList.remove(num);
			}else{
				
				if( CommonView.todoItemPanel.ItemHeadLabelList.get(i).equals(ItemHeadLabel.this)){
					
					state = true;
					num = i+1;
				}
			}
		}
		

		CommonView.todoItemPanel.refreshViewItemHead();
	
		
		
	}
	@Override
	public void mousePressed(MouseEvent e) {

		
	}
	@Override
	public void mouseReleased(MouseEvent e) {
		
		
	}
	@Override
	public void mouseEntered(MouseEvent e) {
		setForeground(new Color(220, 20, 60));
		this.setCursor(new Cursor(Cursor.HAND_CURSOR));
		
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		setForeground(new Color(30, 144, 255));
		this.setCursor(Cursor.getDefaultCursor());
	}
	
	
}
